import { lazy } from 'react'
import { createBrowserRouter } from "react-router-dom";
// 权限组件
import LoadComp from '@/components/loadComp'
import RouteAuth from '@/components/routeAuth';
// 路由页面
const Login = lazy(() => import("@/pages/login"))
const Layout = lazy(() => import("@/pages/layout"))
const Index = lazy(() => import("@/pages/layout/children/index"))
const ScreenMediate = lazy(() => import("@/pages/layout/children/screen/screenMediate/index"))
const ScreenSession = lazy(() => import("@/pages/layout/children/screen/screenSession/index"))


const NotFound = lazy(() => import("@/pages/404"))

// 主体路由
const router = createBrowserRouter([
    {
        path: "/login",
        element: <RouteAuth><LoadComp><Login /></LoadComp></RouteAuth>
    },
    {
        path: "/",
        element: <RouteAuth><LoadComp><Layout /></LoadComp></RouteAuth>,
        children: [
            // {
            //     // 设置默认显示的二级路由，一级路由访问的时候他也会默认显示
            //     index: true,
            //     element: <Index />
            // },
            {
                path: "index",
                element: <Index />
            },
            {
                path: "screen/screenMediate",
                element: <RouteAuth><LoadComp><ScreenMediate /></LoadComp></RouteAuth>
            },
            {
                path: "screen/screenSession",
                element: <RouteAuth><LoadComp><ScreenSession /></LoadComp></RouteAuth>
            },
        ]
    }, {
        path: "*",
        element: <LoadComp><NotFound /></LoadComp>
    }
])
export default router